package railRoad.web.slaves;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import railRoad.Route;
import railRoad.Schedule;
import railRoad.web.slaves.interfaces.ISlaveServlet;

public class CreateOrderServlet implements ISlaveServlet {

	public void work(HttpServletRequest req, HttpServletResponse resp)
			throws IOException, ServletException {
		req.getSession(true).setAttribute("body", "/pages/select_route.jsp");

		Schedule schedule = Schedule.getInstance();
		int size = schedule.size();

		ArrayList<Route> routes = new ArrayList<Route>(size);

		for (int i = 0; i < size; i++)
			routes.add(schedule.getRouteAt(i));

		req.getSession().setAttribute("routes", routes);

		resp.sendRedirect("/index.jsp");

	}//work

}//CreateOrderServlet
